﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;

namespace Winproof.Regi
{
    class RegistryInfo
    {
        // HKEY_LOCAL_MACHINE

        // 윈도우 설치 정보
        //  - RegisteredOwner : 사용자이름
        //  - SystemRoot : 윈도우 설치된 Path
        //  - ProductName : 윈도우 설치 버전 
        //  - CSDVersion :  Service 버전
        //  - InstallDate : 윈도우 설치 시간
        const string WindowsInstallInfo = @"\SOFTWARE\Microsoft\Windows NT\CurrentVersion";

        public class WindowsInstall
        {
            public string RegisteredOwner { get; set; }
            public string SystemRoot { get; set; }
            public string ProductName { get; set; }
            public string CSDVersion { get; set; }
            public string InstallDate { get; set; }
        }       

        public RegistryInfo()
        {
            WindowsInstall InstallInfo = ReadWindowsInstallRegistry();
        }

        private WindowsInstall ReadWindowsInstallRegistry()
        {
            RegistryKey reg = Registry.LocalMachine;
            WindowsInstall winIns = null;
            reg = reg.OpenSubKey(WindowsInstallInfo, true);
            if (reg == null)
                return winIns;

            winIns.RegisteredOwner = (string)reg.GetValue("RegisteredOwner");
            winIns.SystemRoot = (string)reg.GetValue("SystemRoot");
            winIns.ProductName = (string)reg.GetValue("ProductName");
            winIns.CSDVersion = (string)reg.GetValue("CSDVersion");
            winIns.InstallDate = (string)reg.GetValue("InstallDate");

            return winIns;
        }
    }
}
